package cn.mrlong.aavdemo.costom;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import cn.mrlong.aavdemo.ImageViewActivity;

/**
 * @author MrLong
 * @version 1.0
 * @date 2021/01/26 下午 03:33
 */
public class CostomView extends View {
    Paint paint = new Paint();
    Bitmap bitmap;

    public CostomView(Context context) {
        this(context, null);

    }

    public CostomView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CostomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        bitmap = BitmapFactory.decodeFile(ImageViewActivity.url);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (null != bitmap) {
            canvas.drawBitmap(bitmap, 0, 0, paint);
        }
    }
}
